package Default;

import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.Random;

public class GenerateSensorsMap {

	/**
	 * @param args
	 */
	BufferedWriter out=null;
	String fileName=new String();
	public GenerateSensorsMap()
	{
		
	}
	public void setFileName(String _name)
	{
		fileName=_name;
	}
	
	public void generateSensorsMap(String _name)
	{
		setFileName(_name);
		//int [][]grid=new int[100][200];
		int [][]grid=new int[Variables.gridSizeY][Variables.gridSizeX];
		int id=1;
		Random rand=new Random();
		int randX, randY;
		String number=new String();
		try{
		out=new BufferedWriter(new FileWriter(fileName+".txt"));
		
		
		//all_agents=new ArrayList<Agent>();
		//Agent tmp_agent;
		for(int i=0;i<Variables.num_of_agents;i++)
		//for(int i=0;i<10;i++)
		{
			//System.out.println("hi");
			do{
				randX=rand.nextInt(Variables.gridSizeX);
				randY=rand.nextInt(Variables.gridSizeY);
				//randX=rand.nextInt(200);
				//randY=rand.nextInt(100);
			}while(grid[randY][randX]!=0);
			//tmp_agent=new Agent(/*envi,*/id,randX,randY,Variables.energy);
			//all_agents.add(tmp_agent);
			grid[randY][randX]=id;
			number=Integer.toString(randX);
			out.write(number);
			out.write(" ");
			number=Integer.toString(randY);
			out.write(number);
			out.write(" ");
			id++;
			
		}	
		out.newLine();
		out.flush();
			//tmp_agent.data_list.add(new Data(id,0));
		out.close();
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}
	
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		System.out.println("hi");
		GenerateSensorsMap generate=new GenerateSensorsMap();
		generate.generateSensorsMap("myFile");
		System.out.println("end");
	}

}
